home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / initrd.lz / initrd / scripts / casper-bottom / 14locales < prev    next >
Encoding:
Text File  |  2009-10-28  |  1.4 KB  |  68 lines

  1. #! /bin/sh
  2.  
  3. PREREQ=""
  4. DESCRIPTION="Setting up locales..."
  5.  
  6. . /scripts/casper-functions
  7.  
  8. prereqs()
  9. {
  10.        echo "$PREREQ"
  11. }
  12.  
  13. case $1 in
  14. # get pre-requisites
  15. prereqs)
  16.        prereqs
  17.        exit 0
  18.        ;;
  19. esac
  20.  
  21. log_begin_msg "$DESCRIPTION"
  22.  
  23. if [ -e /root/etc/default/locale ]; then
  24.     grep_file=/root/etc/default/locale
  25. elif [ -e /root/etc/environment ]; then # Old locales policy
  26.     grep_file=/root/etc/environment
  27. fi
  28.  
  29. if [ -n "${grep_file}" ]; then
  30.     # use rootfs configured locale
  31.     locale=$(grep -s 'LANG=' ${grep_file} | sed s/'LANG='// | tr -d '"' )
  32. fi
  33.  
  34. # commandline
  35. for x in $(cat /proc/cmdline); do
  36.     case $x in
  37.     debian-installer/language=*)
  38.         language=${x#debian-installer/language=}
  39.         locale="$(lang2locale "$language")"
  40.         set_locale="true"
  41.         ;;
  42.     debian-installer/locale=*)
  43.         locale=${x#debian-installer/locale=}
  44.         set_locale="true"
  45.         ;;
  46.     locale=*)
  47.         locale=${x#locale=}
  48.         set_locale="true"
  49.         ;;
  50.     esac
  51. done
  52.  
  53. if [ -z "${locale}" ]; then
  54.     # Set a default one
  55.     locale=en_US.UTF-8
  56.     set_locale="true"
  57. fi
  58.  
  59. if [ "${set_locale}" ]; then
  60.     LANG=$(grep "^${locale}" /root/usr/share/i18n/SUPPORTED | grep UTF-8 |sed -e 's, .*,,' -e q)
  61.     printf 'LANG="%s"\n' "${LANG}" >> /root/etc/default/locale
  62.     printf 'LANG="%s"\n' "${LANG}" >> /root/etc/environment
  63.     printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen
  64.     chroot /root /usr/sbin/locale-gen "${LANG}"
  65. fi
  66.  
  67. log_end_msg
  68.